/**
 * Module dependencies.
 */

var express = require('express')
    // middleware
    ,
    compress = require("compression"),
    bodyParser = require("body-parser"),
    favicon = require("static-favicon"),
    logger = require("morgan") // logger
    ,
    methodOverride = require("method-override"),
    expressSession = require("express-session"),
    errorHandler = require("errorhandler"),
    http = require('http'),
    path = require('path'),
    fs = require("fs"),
    cors = require('cors');
var mockups = require('./mockapi')
var app = express();


var port = parseInt(process.env.PORT) || 3000;
app.set('port', port);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(logger("combined"));
app.use(expressSession({
    secret: "your secret here",
    resave: false,
    saveUninitialized: false
}));
var root = path.join(__dirname, '../client/src')
app.use('/', express.static(root));


var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
    app.use(errorHandler());
}

app.use(cors());
var format = require('util').format;
var formidable = require("formidable");

mockups.setMockups(app)

app.listen(app.get('port'), function() {
    console.log("Express server listening on port " + app.get('port'));
});